using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using T.FAS.Runtime.Action.SPI;
using T.FAS.Runtime.Base.Entity;
using T.ServiceComponent.Cluster.Client;

namespace T.FAS.Runtime.Action.Engine
{
    public class ActionRouterManager
    {
        private const string FASRouter_RedisKey = "FASRouter";
        private static readonly object lockObj = new object();
        private static ActionRouterManager _instance = null;

        private string _curServiceSet = string.Empty;
        private string CurServiceSet
        {
            get
            {
                if (string.IsNullOrEmpty(_curServiceSet))
                    _curServiceSet = GetCurrentServiceSet();
                return _curServiceSet;
            }
        }
        public static ActionRouterManager Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (lockObj)
                    {
                        if (_instance == null)
                            _instance = new ActionRouterManager();
                    }
                }
                return _instance;
            }
        }

        private ActionRouterManager()
        {
        }

        private string GetCurrentServiceSet()
        {
            var data = AppClusterQueryClient.Current.GetCurrentServiceSet();
            return data.ID;
        }
        /// <summary>
        /// 判断是否需要发起远程调用
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool IsRemoteInovke(ActionExecContext context)
        {
#warning 需要元数据把开发应用信息保存上才行
            return false;
            //fix:冗余代码删除 2024.3.28
        }
    }
}
